import { useContext } from 'react';
import { FileSystemContext } from '../../context/FileSystemContext.tsx';
import type { IFileSystemService } from '../../services/fileSystem/types.ts';

/**
 * 文件系统操作Hook
 * 用于在组件中访问文件系统服务
 * 
 * @returns 文件系统服务实例
 */
export function useFileSystem(): IFileSystemService {
    const fileSystemService = useContext(FileSystemContext);

    if (!fileSystemService) {
        throw new Error('useFileSystem must be used within a FileSystemProvider');
    }

    return fileSystemService;
} 